package com.qf.iostream;

import java.io.File;
import java.io.FilenameFilter;

public class FilenameFilterTest {
	public static void main(String[] args) {
		
		//FilenameFilter测试使用，挺好用的...
		//相较于FileFilter可能功能要少一点
		FilterNamesTxt();
		
		
		
		
		
	}
	public static void FilterNamesTxt() {
		
		
		
		File f4 = new File("G:\\武城院\\其他\\Others");
		System.out.println(f4);
		

		
		FilenameFilter filenameFilter = new FilenameFilter() {
			
			@Override
			public boolean accept(File dir, String name) {
			
				if(name.endsWith(".txt")) 					
					return true;							
				return false;
			}
			
		};
		String[] fileNames = f4.list(filenameFilter);
		
		for (int i = 0; i < fileNames.length; i++) {
			System.out.println(fileNames[i]);
		}
		
		
		
		
	}
}
